from appium import webdriver

import time

from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait

desired_caps = dict()

# 设置中文可输入
desired_caps['unicodeKeyboard'] = True
desired_caps['resetKeyboard'] = True
# 配置 appium
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = '111'
desired_caps['appPackage'] = 'org.gushiwen.gushiwen'
desired_caps['appActivity'] = 'local.z.androidshared.login.RegisterActivity'
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

# 全局等待5s
driver.implicitly_wait(5)

# 获取设置中， 关于注册 的属性
mobial = driver.find_elements(By.ID, 'org.gushiwen.gushiwen:id/registerBtn')
print(mobial[-1].location)  # x, y
print(mobial[-1].size)  # 高和宽

# 不点击勾选同意《用户协议》和《隐私政策》检查注册是否可用
for i in mobial:
    print(i.get_attribute('enabled'))  # 不可用
    # print(i.get_attribute('text'))
    # print(i.get_attribute('name'))
    # print(i.get_attribute('resourceId'))

    # 点击点击勾选同意《用户协议》和《隐私政策》
driver.find_element(By.ID, 'org.gushiwen.gushiwen:id/agreementCheck').click()
# 点击勾选同意《用户协议》和《隐私政策》检查注册是否可用
for i in mobial:
    print(i.get_attribute('enabled'))  # 可用

time.sleep(3)

driver.quit()
